import networkx as nx
from sim import sim
import sys, os

def ft(k=2):
    G = nx.Graph()


    for i in range(k):
        for j in range(int(k/2)):
            G.add_node('tor_%s_%s' % (i, j))
            G.add_node('agg_%s_%s' % (i, j))

    for i in range(int(k/2)):
        for j in range(int(k/2)):
            G.add_node('core_%s_%s' % (i, j))

    for i in range(k):
        for j in range(int(k/2)):
            for m in range(int(k/2)):
                G.add_node('h_%s_%s_%s' % (i, j, m))
                G.add_edge('tor_%s_%s' % (i, j), 'h_%s_%s_%s' % (i, j, m))

    for i in range(k):
        for j in range(int(k/2)):
            for m in range(int(k/2)):
                G.add_edge('agg_%s_%s' % (i, j), 'tor_%s_%s' % (i, m))
                
                G.add_edge('agg_%s_%s' % (i, j), 'core_%s_%s' % (j, m))

            
    return G

def bgp():
    G = nx.Graph()
    G.add_nodes_from(['r1', 'r2', 'r3', 'r4'])

if __name__ == '__main__':
    k = 2
    if len(sys.argv) > 1:
        k = int(sys.argv[1])
    os.system('rm -f log')
    g = ft(k)
    sim(g)